//
//  WebViewController.m
//  LittleSummary
//
//  Created by 郝旭珊 on 2018/2/7.
//  Copyright © 2018年 郝旭珊. All rights reserved.
//

#import "WebViewController.h"

@interface WebViewController ()<UIWebViewDelegate>
@property (nonatomic, strong) UIWebView *webView;
@end

@implementation WebViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    self.webView.delegate = self;
}

- (void)loadView{
    [super loadView];
    self.webView = [[UIWebView alloc]initWithFrame:self.view.frame];
    self.view = self.webView;
}



#pragma mark - UIWebViewDelegate

- (void)webViewDidStartLoad:(UIWebView *)webView{
    //禁止双击, 手势捏合放大
    NSString *injectionJSString = @"var script = document.createElement('meta');"
    "script.name = 'viewport';"
    "script.content=\"width=device-width, initial-scale=1.0,maximum-scale=1.0, minimum-scale=1.0, user-scalable=no\";"
    "document.getElementsByTagName('head')[0].appendChild(script);";
    [webView stringByEvaluatingJavaScriptFromString:injectionJSString];

    //去除长按后出现的文本选取框
    [webView stringByEvaluatingJavaScriptFromString:
     @"document.documentElement.style.webkitUserSelect='none';"];

    //获取高度
    CGFloat webViewH = [[webView stringByEvaluatingJavaScriptFromString:@"document.body.scrollHeight"] floatValue];

}

- (void)webViewDidFinishLoad:(UIWebView *)webView{

}


- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType{
    return true;
}


@end
